/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-01-10 16:20:36
 * @LastEditors: huangtianyang
 * @LastEditTime: 2023-03-15 17:57:42
 * @FilePath: \cxl-h5\src\apis\upload\index.ts
 */
import { request as axios } from '@/axios/index'

/**
 * 获取上传接口的token
 * @returns
 */
export const getUploadToken = () => {
    return axios({
        method: 'get',
        url: '/api/system/file/token',
        params: { showPub: true }
    })
}

/**
 * 上传文件
 * @param file
 * @param showPub
 * @returns
 */
export const uploadFile = (data: FormData) => {
    return axios({
        method: 'post',
        url: '/api/system/file/upload',
        data
    })
}

export const uploadFileBase64 = (byteData: string) => {
    return axios({
        method: 'post',
        url: '/api/system/file/upload/body',
        data: {
            byteData,
            showPub: true
        }
    })
}
